<html>
<head><meta charset="utf-8"><title>output bin filename · t-cargo · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/index.html">t-cargo</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/output.20bin.20filename.html">output bin filename</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="244607380"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/output%20bin%20filename/near/244607380" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tejas Sanap <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/output.20bin.20filename.html#244607380">(Jul 01 2021 at 18:22)</a>:</h4>
<p>Hi all,<br>
I'm working on the following PR: <a href="https://github.com/rust-lang/cargo/pull/9627">https://github.com/rust-lang/cargo/pull/9627</a><br>
At this point, I'm trying to figure out how to attach arguments to rustc. Much to my own dismay, I'm not able to find the code where this happens. Could someone please guide me?</p>
<p>According to what I could debug, I need to edit this method: <a href="https://github.com/rust-lang/cargo/blob/4952979031e2cf1d901c817a32e25a156a19db4c/src/cargo/ops/cargo_compile.rs#L323">https://github.com/rust-lang/cargo/blob/4952979031e2cf1d901c817a32e25a156a19db4c/src/cargo/ops/cargo_compile.rs#L323</a></p>



<a name="244630537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/output%20bin%20filename/near/244630537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/output.20bin.20filename.html#244630537">(Jul 01 2021 at 21:42)</a>:</h4>
<p><span class="user-mention" data-user-id="424019">@Tejas Sanap</span> The code for setting the arguments is in <a href="https://github.com/rust-lang/cargo/blob/master/src/cargo/core/compiler/mod.rs"><code>core::compiler</code></a>.  <code>build_base_args</code> would be a good place to start looking.</p>



<a name="244630560"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/output%20bin%20filename/near/244630560" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/output.20bin.20filename.html#244630560">(Jul 01 2021 at 21:42)</a>:</h4>
<p>I don't think there needs to be any changes to the BuildContext for this change.</p>



<a name="244796731"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/output%20bin%20filename/near/244796731" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tejas Sanap <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/output.20bin.20filename.html#244796731">(Jul 03 2021 at 10:29)</a>:</h4>
<p><span class="user-mention" data-user-id="120518">@Eric Huss</span> Thanks :) that helped me out a bunch.<br>
<span class="user-mention" data-user-id="116015">@Alex Crichton</span>  I'm almost finished making the changes. I'm stuck at one point, though. I'm using <code>--emit=link</code> flag to tell <code>rustc</code> what to name the binary, however, it takes a full path. To do this, I'm using the <code>cx.files().out_dir(unit)</code> to get the directory where we are saving our created binaries.</p>
<p>However, this path leads to <code>/target/debug/deps</code> instead of <code>target/debug</code>. The test which I have written fails because the binary gets created in the wrong directory. Am I missing something here?</p>
<p>Shouldn't the <code>out_dir</code> be <code>target/debug</code>?</p>



<a name="244797667"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/output%20bin%20filename/near/244797667" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/output.20bin.20filename.html#244797667">(Jul 03 2021 at 10:53)</a>:</h4>
<p>Most files are first written to <code>target/debug/deps/</code> including a hash in the name and only then hardlinked to <code>target/debug/</code> without a hash in the name.</p>



<a name="244798571"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/output%20bin%20filename/near/244798571" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tejas Sanap <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/output.20bin.20filename.html#244798571">(Jul 03 2021 at 11:14)</a>:</h4>
<p>That complicates things. :(</p>



<a name="244819168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/output%20bin%20filename/near/244819168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tejas Sanap <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/output.20bin.20filename.html#244819168">(Jul 03 2021 at 18:52)</a>:</h4>
<p>So, I figured out a better way to solve this issue: <a href="https://github.com/whereistejas/cargo/commit/5a14091021f129e68c7d46208555747ab1b56cad"><code>5a14091</code></a></p>
<p>If I change the return value for the <a href="https://github.com/rust-lang/cargo/blob/3ebb5f15a940810f250b68821149387af583a79e/src/cargo/util/toml/mod.rs#L1980-L1985"><code>name</code></a> method in the <code>TomlTarget</code> impl, that seems to solve our problem. But, I'm not aware of how this will affect future enhancements.</p>



<a name="245013335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/output%20bin%20filename/near/245013335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tejas Sanap <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/output.20bin.20filename.html#245013335">(Jul 06 2021 at 09:14)</a>:</h4>
<p>Hi <span class="user-mention" data-user-id="116015">@Alex Crichton</span> <span class="user-mention" data-user-id="120179">@Eh2406</span> can I please get a review for the following PR: <a href="https://github.com/rust-lang/cargo/pull/9627">https://github.com/rust-lang/cargo/pull/9627</a> ?<br>
I am at a point, where I need some guidance on how to proceed.</p>



<a name="245265774"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/output%20bin%20filename/near/245265774" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/output.20bin.20filename.html#245265774">(Jul 08 2021 at 02:14)</a>:</h4>
<p>I don't know this part of the code all that well. Sorry. <span class="user-mention" data-user-id="120518">@Eric Huss</span> may have more opinions.</p>



<a name="245400615"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/output%20bin%20filename/near/245400615" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tejas Sanap <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/output.20bin.20filename.html#245400615">(Jul 09 2021 at 04:43)</a>:</h4>
<p>hi <span class="user-mention" data-user-id="120518">@Eric Huss</span> , thank you for your comment on the PR. I had a couple of questions. They may sound really stupid, but they are purely for my understanding and clarity.</p>
<ol>
<li>What are the disadvantages of going with the second approach I mentioned? The <a href="https://github.com/rust-lang/cargo/blob/cc80b40f1c78dda0d57f0df72ccb7fee811951eb/src/cargo/util/toml/mod.rs#L1980-L1985"><code>name</code></a> method does exactly what we want it to.<br>
My naive understanding is that it is often better to use re-use the same fields instead of adding new ones.<br>
I have ran the <a href="https://github.com/whereistejas/cargo/commit/5a14091021f129e68c7d46208555747ab1b56cad">code changes</a> made according to the second approach against all the tests in the testsuite. It passes all of them.</li>
</ol>



<a name="245455677"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/output%20bin%20filename/near/245455677" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/output.20bin.20filename.html#245455677">(Jul 09 2021 at 15:11)</a>:</h4>
<p><code>name</code> is used for <code>crate_name</code> which is used for things like the <code>--crate-name</code> flag, which IIRC doesn't allow non-rust identifiers.  I think it would cause problems there, and possibly elsewhere, I'm not sure.</p>



<a name="245460013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/output%20bin%20filename/near/245460013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/output.20bin.20filename.html#245460013">(Jul 09 2021 at 15:46)</a>:</h4>
<p>for example, on unix the executable name is the crate name directly, but on windows a <code>.exe</code> extension is added.</p>



<a name="245470485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/output%20bin%20filename/near/245470485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tejas Sanap <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/output.20bin.20filename.html#245470485">(Jul 09 2021 at 17:11)</a>:</h4>
<p><span class="user-mention" data-user-id="120518">@Eric Huss</span> <span class="user-mention" data-user-id="224471">@Lokathor</span> oh, I see... thanks :)</p>



<a name="245703836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/output%20bin%20filename/near/245703836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tejas Sanap <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/output.20bin.20filename.html#245703836">(Jul 12 2021 at 15:36)</a>:</h4>
<p>Hi <span class="user-mention" data-user-id="120518">@Eric Huss</span> <span class="user-mention" data-user-id="116015">@Alex Crichton</span>,<br>
I have once again reached a point, where I need some code review and guidance. Looking forward to your comments :)</p>



<a name="246457664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/output%20bin%20filename/near/246457664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tejas Sanap <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/output.20bin.20filename.html#246457664">(Jul 19 2021 at 13:56)</a>:</h4>
<p>Hi <span class="user-mention" data-user-id="120518">@Eric Huss</span> / <span class="user-mention" data-user-id="116015">@Alex Crichton</span> ,<br>
I have finished making all the changes from my side for PR <a href="https://github.com/rust-lang/cargo/pull/9627/">#9627</a>, as close to  finished as possible. Could you please take a look, is it good enough from your side as well?</p>



<a name="246818730"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/output%20bin%20filename/near/246818730" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tejas Sanap <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/output.20bin.20filename.html#246818730">(Jul 22 2021 at 08:00)</a>:</h4>
<p>Hi,<br>
Just a gentle reminder, asking for a review on the following PR: <a href="https://github.com/rust-lang/cargo/pull/9627">https://github.com/rust-lang/cargo/pull/9627</a></p>



<a name="246848719"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/output%20bin%20filename/near/246848719" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/output.20bin.20filename.html#246848719">(Jul 22 2021 at 13:47)</a>:</h4>
<p><span class="user-mention" data-user-id="424019">@Tejas Sanap</span> Please have some patience. This is a volunteer project, and we are often busy, so it can take some time to get to reviews.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>